package com.fasteat.controller;

import com.fasteat.common.entity.Result;
import com.fasteat.common.entity.StatusCode;
import com.fasteat.common.util.FileUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/file")
public class FileController {

    /**
     * 文件上传
     * @param file
     * @return
     */
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public Result upload(@RequestParam("file") MultipartFile file){
        String url = FileUtil.upload(file);
        return new Result(true, StatusCode.OK, "上传成功", url);
    }
}
